home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / etc / init.d / cups < prev    next >
Text File  |  2008-10-20  |  3KB  |  103 lines

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          cups
  4. # Required-Start:    $syslog
  5. # Required-Stop:     $syslog
  6. # Should-Start:      $network avahi
  7. # Should-Stop:       $network
  8. # X-Start-Before:    samba
  9. # X-Stop-After:      samba
  10. # Default-Start:     2 3 4 5
  11. # Default-Stop:      1
  12. # Short-Description: CUPS Printing spooler and server
  13. ### END INIT INFO
  14.  
  15. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  16. DAEMON=/usr/sbin/cupsd
  17. NAME=cupsd
  18. PIDFILE=/var/run/cups/$NAME.pid
  19. DESC="Common Unix Printing System"
  20.  
  21. unset TMPDIR
  22.  
  23. test -x $DAEMON || exit 0
  24.  
  25. if [ -r /etc/default/cups ]; then
  26.   . /etc/default/cups
  27. fi
  28.  
  29. . /lib/lsb/init-functions
  30.  
  31. # Get the timezone set.
  32. if [ -z "$TZ" -a -e /etc/timezone ]; then
  33.     TZ=`cat /etc/timezone`
  34.     export TZ
  35. fi
  36.  
  37. restart_xprint() {
  38.     if [ -n "$success" ] && [ -x /etc/init.d/xprint ]; then
  39.         invoke-rc.d xprint force-reload || true
  40.     fi
  41. }
  42.  
  43. case "$1" in
  44.   start)
  45.     log_begin_msg "Starting $DESC: $NAME"
  46.     chown root:lpadmin /usr/share/ppd/custom 2>/dev/null || true
  47.     chmod 3775 /usr/share/ppd/custom 2>/dev/null || true
  48.  
  49.     mkdir -p `dirname "$PIDFILE"`
  50.     if [ "$LOAD_LP_MODULE" = "yes" -a -f /usr/lib/cups/backend/parallel \
  51.              -a -f /proc/devices -a -f /proc/modules -a -x /sbin/modprobe ]; then
  52.       modprobe -q lp || true
  53.       modprobe -q ppdev || true
  54.     fi
  55.  
  56.     start-stop-daemon --start --quiet --oknodo --pidfile "$PIDFILE" --exec $DAEMON && success=1
  57.  
  58.     log_end_msg $?
  59.     restart_xprint
  60.     ;;
  61.   stop)
  62.     log_begin_msg "Stopping $DESC: $NAME"
  63.     start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE --name $NAME && success=1
  64.     log_end_msg $?
  65.     restart_xprint
  66.     ;;
  67.   reload|force-reload)
  68.        log_begin_msg "Reloading $DESC: $NAME"
  69.        start-stop-daemon --stop --quiet --pidfile $PIDFILE --name $NAME --signal 1 && success=1
  70.        log_end_msg $?
  71.     restart_xprint
  72.        ;;
  73.   restart)
  74.     log_begin_msg "Restarting $DESC: $NAME"
  75.     if start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE --name $NAME; then
  76.         start-stop-daemon --start --quiet --pidfile "$PIDFILE" --exec $DAEMON && success=1
  77.     fi
  78.     log_end_msg $?
  79.     restart_xprint
  80.     ;;
  81.   status)
  82.     echo -n "Status of $DESC: "
  83.     if [ ! -r "$PIDFILE" ]; then
  84.         echo "$NAME is not running."
  85.         exit 3
  86.     fi
  87.     if read pid < "$PIDFILE" && ps -p "$pid" > /dev/null 2>&1; then
  88.         echo "$NAME is running."
  89.         exit 0
  90.     else
  91.         echo "$NAME is not running but $PIDFILE exists."
  92.         exit 1
  93.     fi
  94.     ;;
  95.   *)
  96.     N=/etc/init.d/${0##*/}
  97.     echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
  98.     exit 1
  99.     ;;
  100. esac
  101.  
  102. exit 0
  103.